package com.lq.ecoldchain.ui.mine.certification.addcertification

import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.lq.ecoldchain.R
import com.lq.ecoldchain.base.BaseNavigator
import com.lq.ecoldchain.base.view.BaseActivity
import com.lq.ecoldchain.databinding.ActivityAddCertificationBinding
import com.lq.ecoldchain.util.CameraUtil
import com.lq.ecoldchain.util.QiNiuUtils
import com.lq.ecoldchain.util.logi
import kotlinx.android.synthetic.main.activity_add_certification.*
import kotlinx.android.synthetic.main.activity_verified.*
import org.kodein.di.Kodein
import org.kodein.di.generic.instance

/*
*2019/1/16 0016  14:58
*function by lq
*/
@Route(path = BaseNavigator.addCertification)
class AddCertificationActivity : BaseActivity<ActivityAddCertificationBinding>() {
    override val layoutId = R.layout.activity_add_certification
    override val viewDelegate: AddCertificationDelegate by instance()
    override fun initView() {
        binding.delegate = viewDelegate
        titleText("身份证明")
    }

    override val kodein = Kodein.lazy {
        extend(parentKodein)
        import(addCertificationKodeinModule)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == RESULT_OK) {
            CameraUtil.handlePhoto(requestCode, data?.data, addCertificationIv, object : QiNiuUtils.OnQiNiuListener {
                override fun uploadSuccess(url: String) {
                    viewDelegate.viewModel.imgUrl.value = url
                    logi { url }
                }
            })
        }
    }
}